﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;


class Exercises
{
    static void Main(string[] args)
    {
        string text = "zuzi@mail.bg;; ciki@duduk.net, "+"bob@mail.bg\n\nfn12345@fmi.uni-sofia.bg\n" +"    mente@eu.int | , , ;;; gero@dir.bg";
        List<string> emails = ExtractEmailsFromText(text);

        foreach (string email in emails)
        {
            Console.WriteLine(email);
        }

    }

    static bool IsRealNumber(string number)
    {
        Regex realNumberRegex = new Regex(@"\A
                                                (
                                                    -?
                                                    (([1-9][0-9]*)|0)
                                                    (\.[0-9]+)?
                                                ) 
                                            \Z", RegexOptions.IgnorePatternWhitespace);
        Regex negativeZero = new Regex(@"\A
                                            -0(.0*)?
                                         \Z", RegexOptions.IgnorePatternWhitespace);
        bool result = negativeZero.IsMatch(number);
        if (result)
        {
            return false;
        }
        result = realNumberRegex.IsMatch(number);
        return result;
    }

    static List<string> ExtractEmailsFromText(string text)
    {
        Regex emailRegex = new Regex(@"\A
                                            [a-zA-Z0-9._%-]+@[a-zA-Z0-9-]+(\.[a-zA-Z]{2,4})+
                                       \Z", RegexOptions.IgnorePatternWhitespace);

        List<string> emails = new List<string>();

        Match match = emailRegex.Match(text);
        while (match.Success)
        {
            emails.Add(match.ToString());
            match = match.NextMatch();
        }

        return emails;
    }
}

